// pages/personal/mycomment/mycomment.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    mycomment: []
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getcommentbyuserid()
  },
  getcommentbyuserid: function () {
    let that = this
    const db = wx.cloud.database()
    db.collection('comment').orderBy('date', 'asc').where({
      "userid": wx.getStorageSync('openid'),
    }).get().then(res => {
      that.setData({
        mycomment: res.data
      })
    })


  },
  removecomment: function (e) {
    let movieid = e.currentTarget.dataset.movieid;
    const db = wx.cloud.database();
    db.collection("comment").where({
      "movieid": movieid
    }).remove().then(res => {
      if (res.stats.removed == 1) {
        wx.showToast({
          title: '删除成功！',
        })
        this.getcommentbyuserid()
      }
    })

  }

})